//
//  SevenCollectionViewCell.m
//  B
//
//  Created by 王展 on 15/11/6.
//  Copyright © 2015年 wangzhan. All rights reserved.
//

#import "SevenCollectionViewCell.h"

@implementation SevenCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSevenView];
    }
    return self;
}

-(void)createSevenView
{
    UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height)];
    backView.backgroundColor = [UIColor colorWithRed:0.176 green:0.323 blue:0.317 alpha:1.000];
    backView.alpha = 0.2;
    [self.contentView addSubview:backView];
    
    self.week = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 60 * XWIDTH, 40 * XHIGHT)];
//    self.week.backgroundColor = [UIColor redColor];
    self.week.font = [UIFont systemFontOfSize:16 * XWIDTH];
    [self.week setTextAlignment:NSTextAlignmentCenter];
    self.week.textColor = [UIColor whiteColor];
    [self.contentView addSubview:self.week];
    
    self.weather = [[UILabel alloc] initWithFrame:CGRectMake(0, 40 * XHIGHT, 60 * XWIDTH, 30 * XHIGHT)];
    self.weather.font = [UIFont systemFontOfSize:10 * XWIDTH];
//    self.weather.backgroundColor = [UIColor redColor];
    [self.weather setTextAlignment:NSTextAlignmentCenter];
    self.weather.textColor = [UIColor whiteColor];
    [self.contentView addSubview:self.weather];
    self.weather.numberOfLines = 0;
    
    self.temp_high = [[UILabel alloc] initWithFrame:CGRectMake(0, 140 * XHIGHT, 60 * XWIDTH, 30 * XHIGHT)];
//    self.temp_high.backgroundColor = [UIColor redColor];
    self.temp_high.textColor = [UIColor whiteColor];
    [self.temp_high setTextAlignment:NSTextAlignmentCenter];
    self.temp_high.font = [UIFont systemFontOfSize:14 * XWIDTH];
    [self.contentView  addSubview:self.temp_high];
    
    self.temp_low = [[UILabel alloc] initWithFrame:CGRectMake(0, 260 * XHIGHT, 60 * XWIDTH, 30 * XHIGHT)];
//    self.temp_low.backgroundColor = [UIColor redColor];
    self.temp_low.textColor = [UIColor whiteColor];
    [self.temp_low setTextAlignment:NSTextAlignmentCenter];
    self.temp_low.font = [UIFont systemFontOfSize:14 * XWIDTH];
    [self.contentView addSubview:self.temp_low];
    
    self.days = [[UILabel alloc] initWithFrame:CGRectMake(0, 300 * XHIGHT, 60 * XWIDTH, 40 * XHIGHT)];
//    self.days.backgroundColor = [UIColor redColor];
    self.days.textColor = [UIColor whiteColor];
    [self.days setTextAlignment:NSTextAlignmentCenter];
    self.days.font = [UIFont systemFontOfSize:16 * XWIDTH];
    [self.contentView addSubview:self.days];
    
    self.wind = [[UILabel alloc] initWithFrame:CGRectMake(0, 340 * XHIGHT, 60 * XWIDTH, 30 * XHIGHT)];
//    self.wind.backgroundColor = [UIColor redColor];
    self.wind.textColor = [UIColor whiteColor];
    [self.wind setTextAlignment:NSTextAlignmentCenter];
    self.wind.font = [UIFont systemFontOfSize:10 * XWIDTH];
    [self.contentView addSubview:self.wind];
    self.wind.numberOfLines = 0;
    
    self.winp = [[UILabel alloc] initWithFrame:CGRectMake(0, 365 * XHIGHT, 60 * XWIDTH, 50 * XHIGHT)];
//    self.winp.backgroundColor = [UIColor redColor];
    self.winp.textColor = [UIColor whiteColor];
    [self.winp setTextAlignment:NSTextAlignmentCenter];
    self.winp.font = [UIFont systemFontOfSize:14 * XWIDTH];
    [self.contentView addSubview:self.winp];
    self.winp.numberOfLines = 0;
    
    
    self.dotView1 = [[UIView alloc] init];
    [self.contentView addSubview:self.dotView1];
    self.dotView1.layer.cornerRadius = 3;
    self.dotView1.backgroundColor = [UIColor whiteColor];
    
    
    self.dotView2 = [[UIView alloc] init];
    [self.contentView addSubview:self.dotView2];
    self.dotView2.layer.cornerRadius = 3;
    self.dotView2.backgroundColor = [UIColor whiteColor];
}

-(void)setSeven:(Seven *)seven
{
    _seven = seven;
    self.week.text = self.seven.week;
    self.weather.text = self.seven.weather;
    self.temp_high.text = self.seven.temp_high;
    self.temp_low.text = self.seven.temp_low;
    self.days.text = [self.seven.days substringFromIndex:5];
    self.wind.text = self.seven.wind;
    self.winp.text = self.seven.winp;
    
    
    CGFloat high = [self.seven.temp_high floatValue];
    self.dotView1.frame = CGRectMake(0, 0, 6 * XWIDTH, 6 * XWIDTH);
    self.dotView1.center = CGPointMake(30 * XWIDTH, 170 * XHIGHT - high * 2.25);
    
    CGFloat low = [self.seven.temp_low floatValue];
    self.dotView2.frame = CGRectMake(0, 0, 6 * XWIDTH, 6 * XWIDTH);
    self.dotView2.center = CGPointMake(30 * XWIDTH, 240 * XHIGHT - low * 2.25);
    
    self.temp_high.center = CGPointMake(30 * XWIDTH, 155 * XHIGHT - high * 2.25);
    self.temp_low.center = CGPointMake(30 * XWIDTH, 255 * XHIGHT - low * 2.25);
    
}

@end
